import * as constants from './constants'
import axios from './../../../axios/axios'
import Cookies from  'js-cookie'

const changeLogin=(value)=>({
    type:constants.LOGIN,
    value
})



export const login=(name,password)=>{
    return (dispatch)=> {
        axios.ajax({
            url:'/cloud-long-upms/sysUser/login',
            method:'get',
            data:{
                params:{
                    name:name,
                    password:password
                }
            }
        }).then((res)=>{
            console.log(res)
            dispatch(changeLogin(res.data))
            Cookies.set('name',res.data.name)
            Cookies.set('token',res.data.token)
        })
    }

}

